class MigratePageUserGroupAssociation < ActiveRecord::Migration
  class << self
    def up
      create_lookup_table(:pages,:user_groups)
      remove_column(:pages,:is_private)
      add_column(:pages, :do_hide, :boolean, :default => false)
      add_column(:pages, :enabled, :boolean, :default => true)
      pages = Page.find_all
      pages.each do |page|
        page.enabled = true
        page.save
      end
    end

    def down
      drop_lookup_table(:pages,:user_groups)
      add_column(:pages, :is_private, :boolean, :default => false)
      remove_column(:pages, :do_hide)
      remove_column(:pages, :enabled)
    end
  end #end class block
end
